// import 'package:fijkplayer/fijkplayer.dart';
import 'package:flutter/material.dart';

@deprecated
class VideoIntercom extends StatefulWidget {
  @override
  _VideoIntercomState createState() => _VideoIntercomState();
}

class _VideoIntercomState extends State<VideoIntercom> {
  // final FijkPlayer player = FijkPlayer();


  @override
  void initState() {
    super.initState();
    // player.setDataSource(
    //   "rtmp://139.9.203.88/live/livestream",
    //   autoPlay: true,
    // );
    // player.setOption(FijkOption.playerCategory, 'packet-buffering', 0);
    // player.setOption(FijkOption.playerCategory, 'framedrop', 1);

    // player.prepareAsync();
  }

  @override
  void dispose() {
    super.dispose();
    // player.stop();
    // player.dispose();
  }

  AppBar _buildAppBar(BuildContext context) {
    return AppBar(
      leading: IconButton(
        icon: Icon(
          Icons.arrow_back,
          size: 35,
        ),
        onPressed: () => Navigator.of(context).pop(),
      ),
      title: Text(
        "视频",
        style: TextStyle(fontSize: 25),
      ),
      centerTitle: true,
    );
  }

  Widget _buildBody() {
    return Container(
      width: MediaQuery.of(context).size.width,
      child: Column(
        children: [
          SizedBox(
            height: 20,
            width: 20,
          ),
          Container(
            width: 1100,
            height: 618,
            // child: FijkView(
            //   player: player,
            //   fit: FijkFit.cover,
            //   fs: true,
            //   fsFit: FijkFit.cover,
            // ),
          ),
          FutureBuilder(
              future: null,
              builder: (context, snap) {
                if (snap.hasData) {
                  // return CameraDisplay(
                  //   cameras: snap.data,
                  // );
                }
                return Container();
              }),
          Expanded(
            child: SizedBox(
              height: 20,
              width: 20,
            ),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: _buildAppBar(context),
      body: _buildBody(),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.play_arrow),
        onPressed: () {
          // player.start();
        },
      ),
    );
  }
}

// class CameraDisplay extends StatefulWidget {
//   final List<CameraDescription> cameras;
//
//   const CameraDisplay({Key key, this.cameras}) : super(key: key);
//
//   @override
//   _CameraDisplayState createState() => _CameraDisplayState(cameras);
// }

// class _CameraDisplayState extends State<CameraDisplay> {
//   final List<CameraDescription> cameras;
//   CameraController controller;
//
//   _CameraDisplayState(this.cameras);
//
//   @override
//   void initState() {
//     super.initState();
//     controller = CameraController(cameras[0], ResolutionPreset.medium);
//     controller.initialize().then((_) {
//       if (!mounted) {
//         return;
//       }
//       setState(() {});
//     });
//   }
//
//   @override
//   void dispose() {
//     controller?.dispose();
//     super.dispose();
//   }
//
//   @override
//   Widget build(BuildContext context) {
//     if (!controller.value.isInitialized) {
//       return Container();
//     }
//     return AspectRatio(
//         aspectRatio: controller.value.aspectRatio,
//         child: CameraPreview(controller));
//   }
// }
